package com.ats.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import com.ats.model.User;
import com.ats.service.GetNoApprovalsService_ty;
import com.ats.serviceimpl.GetNoApprovalServiceImpl;
/**
 * 
 * @author TangRain
 * 
 */
public class GetNoApprovalController_ty extends HttpServlet{
	GetNoApprovalsService_ty gnas =new GetNoApprovalServiceImpl();
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		doPost(req, resp);
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		resp.setCharacterEncoding("utf8");
		
		HttpSession session =req.getSession();
		PrintWriter  pw = resp.getWriter();
		int rows=Integer.parseInt(req.getParameter("rows"));
		int page=Integer.parseInt(req.getParameter("page"));
		int iid =((User)session.getAttribute("user")).getIid();
			JSONObject as=gnas.getNoApprovals(iid,page,rows);
			pw.write(as.toString());
			pw.flush();
			pw.close();
	}
}
